home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
DELPHI32
/
SYS_TOOL
/
MULTI020
/
NCONV.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-09-01
|
2KB
|
133 lines
unit NConv;
{ FAST hex conversion routines }
interface
function Byte2FHex(b : byte) : string; { Byte2FHex(15) = '0F' }
function Byte2Hex(b : byte) : string; { Byte2Hex(15) = 'F' }
function Word2FHex(w : word) : string; { Word2FHex(15) = '000F' }
function Word2Hex(w : word) : string; { Word2Hex(15) = 'F' }
implementation
function Byte2FHex(b : byte) : string; assembler;
asm
les di,[@result]
mov dl,[b]
xor dh,dh
mov al,2
stosb
mov ch,2
@@1:
mov cl,4
rol dx,cl
mov al,dh
and al,0Fh
add al,30h
cmp al,3Ah
jb @@2
add al,7
@@2:
stosb
dec ch
jnz @@1
end;
function Byte2Hex(b:byte) : string; assembler;
asm
les di,[@result]
mov dl,[b]
mov al,0
mov dh,al
xor bx,bx
stosb
mov ch,2
mov si,di
@@1:
mov cl,4
rol dx,cl
mov al,dh
and al,0Fh
add al,30h
cmp al,3Ah
jb @@2
add al,7
@@2:
cmp al,'0'
je @@3
stosb
inc bl
@@3:
dec ch
jnz @@1
cmp bl,0
jne @@4
mov al,'0'
stosb
inc bl
@@4:
les di,[@result]
mov al,bl
stosb
end;
function Word2FHex(w : word) : string; assembler;
asm
les di,[@result]
mov dx,[w]
mov al,4
stosb
mov ch,4
@@1:
mov cl,4
rol dx,cl
mov al,dl
and al,0Fh
add al,30h
cmp al,3Ah
jb @@2
add al,7
@@2:
stosb
dec ch
jnz @@1
end;
function Word2Hex(w:word) : string; assembler;
asm
les di,[@result]
mov dx,[w]
mov al,0
xor bx,bx
stosb
mov ch,4
mov si,di
@@1:
mov cl,4
rol dx,cl
mov al,dl
and al,0Fh
add al,30h
cmp al,3Ah
jb @@2
add al,7
@@2:
cmp al,'0'
je @@3
stosb
inc bl
@@3:
dec ch
jnz @@1
cmp bl,0
jne @@4
mov al,'0'
stosb
inc bl
@@4:
les di,[@result]
mov al,bl
stosb
end;
end.